home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / nn.zip / NNGOBACK.SH < prev    next >
Text File  |  1989-06-28  |  2KB  |  104 lines

  1. # prefix is inserted above by make
  2.  
  3. # go $1 days back in the news feed and adjust .nn/rc
  4. # accordingly.
  5.  
  6. USE_HIST=false
  7. if [ "$1" = "-h" ]
  8. then
  9.     USE_HIST=true
  10.     shift
  11. fi
  12.  
  13. if [ $# -ne 1 ]
  14. then
  15.     echo "Usage: $0 [-h] days"
  16.     exit 1
  17. fi
  18.  
  19. if [ $USE_HIST = false ]
  20. then
  21.     if [ -s $DB/active.$1 ]
  22.     then
  23.       nntidy - $DB/active.$1
  24.     else
  25.       echo $0: No suitable copy of the active file exists -- no update
  26.     fi
  27.     exit 0
  28. fi
  29.  
  30. HISTORY="`expr $ACTIVE : '\(/.*/\)'`"history
  31.  
  32. if [ -s "${HISTORY}" ]
  33. then
  34.     :
  35. elif [ -s "${HISTORY}.d/0" ]
  36. then
  37.     HISTORY="${HISTORY}.d/*"
  38. else
  39.     if $NNTP
  40.     then
  41.         echo "$0 is not setup to run with NNTP"
  42.         exit 2
  43.     fi
  44.     echo "Cannot find the history file -- no update"
  45.     exit 1
  46. fi
  47.  
  48. echo Working on your nn record file ... do not run nn until completed
  49.  
  50. echo "NOTICE:  this operation is SLOOOOOOOOWWWWWWWW....."
  51.  
  52. cd
  53. cd .nn
  54. rm -f rc.bak1
  55.  
  56. trap "mv rc.bak1 rc ; echo No changes ; exit 0" 1 2 3 13 14 15
  57.  
  58. mv rc rc.bak1
  59.  
  60. {
  61. echo PHASE_1
  62. # news.group last.art.no first.art.no mod
  63. cat $ACTIVE
  64.  
  65. echo PHASE_2
  66. # + last.read.art.no news.group
  67. cat rc.bak1
  68.  
  69. echo PHASE_3
  70. # from date time news.group/art.no ...
  71. cat  $HISTORY | egrep "`$LIB/date_regexp $1`"
  72. } |
  73. awk '
  74. BEGIN{
  75.     p=0
  76. }
  77. /^PHASE_/ {
  78.     p++
  79.     next
  80. }
  81. p == 1 {
  82.     last[$1]=$2+1
  83.     next
  84. }
  85. p == 2 {
  86.     if (last[$3] > 0) {
  87.         subscr[$3] = $1
  88.         if ($1 == "!") last[$3] = $2 + 1;
  89.     }
  90.     next
  91. }
  92. p == 3 {
  93.     for (i = 4; i <= NF; i++) {
  94.         if (split($i, x, "/") != 2) continue;
  95.         g=x[1]; n=x[2]
  96.         if (subscr[g] == "+" && n < last[g]) last[g] = n
  97.     }
  98. }
  99. END {
  100.     for (g in subscr) printf("%s %06d %s\n", subscr[g], last[g]-1, g)
  101. }' | sort +2 > rc
  102.  
  103. echo "nngoback $1 finished"
  104.